Creating Interactive Visualisations Using R and Shiny

Martin John Hadley Academic Research Technology Specialist

What do you now about the R data visualisation stack?

R

R is a scripting language and a very powerful tool for data analysis and presentation, primarily due to the huge user base and their dedication to developing free and open source libraries/packages covering a vast range of different knowledge domains:

R provides an excellent workflow for reproducible research; combining code with data, textual explanations and interactive data visualisations.

Who’s used RStudio?

RStudio/

RStudio/

RStudio is a free, open-source IDE (integrated development environment) that provides an extremely powerful and friendly interface for developing with R.

RStudio is also the name of the developers of RStudio - they have developed an impressive stack of technologies for making R easier to use and more powerful for reproducible research and creating interactive data visualisatons.

Some of the technology they’ve built includes:

RStudio/

RStudio/
  • The “tidyverse” is a collection of packages maintained by RStudio devs [particularly Hadley Wickham]
  • tidyverse packages play extremely nicely together
  • tidyverse packages are extremely useful for preparing data for interactive visualisations
  • tidyverse packages are highly optimised, often specifically around nitpicky details of bse R (readr is a good example of this)
  • tidyverse is the backbone of the recently published, free online book R for Data Science

Who’s heard of RMarkdown?

RStudio/

RMarkdown/

RMarkdown allows for code, text, images and interactive data visualisations to be combined together in the same document.

This presentation was built using RMarkdown and published to the free hosting platform RPubs.

library(leaflet)
africa_data_points = data.frame(
  lat = rnorm(26, mean = 6.9, sd = 20),
  lng = rnorm(26, mean = 17.7, sd = 20),
  size = runif(26, 5, 10),
  label = letters
  )
leaflet(data = africa_data_points) %>%
  addTiles() %>%
  addCircleMarkers(popup = ~label, radius = ~size, clusterOptions = markerClusterOptions())

Who’s heard of htmlwidgets?

htmlwidgets

htmlwidgets is a framework for binding R to a JavaScript library of choice, and to bundle this functionality into an easy to use library:

library(leaflet)
leaflet() %>%
  addTiles()

The htmlwidgets.org website provides an overview of some of the most popular htmlwidgets:

RStudio/

Interactive tables: